//
//  ZRBottom.m
//  SinaByOC
//
//  Created by 张锐 on 16/3/20.
//  Copyright © 2016年 zhangr. All rights reserved.
//

#import "ZRBottom.h"
#import <Masonry/Masonry.h>
@interface ZRBottom ()

@property (nonatomic,strong) UIButton * zfButton;

@property (nonatomic,strong) UIButton * plButton;

@property (nonatomic,strong) UIButton * zButton;

@property (nonatomic,strong) UIView * leftView;

@property (nonatomic,strong) UIView * rightView;

@end

@implementation ZRBottom

-(instancetype)init{

    self = [super init];
    
    if (self) {
        
        [self setupUI];
        
    }

    return self;

}
-(void)setupUI{

    [self addSubview:self.zfButton];
    
    [self addSubview:self.plButton];
    
    [self addSubview:self.zButton];
    
    [self addSubview:self.leftView];
    
    [self addSubview:self.rightView];
    
    [self.zfButton mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.equalTo(self.mas_left);
        
        make.top.equalTo(self.mas_top);
        
        make.bottom.equalTo(self.mas_bottom);
        
        make.width.equalTo(self.plButton.mas_width);
        
    }];
    
    [self.plButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.leftView.mas_right);
        
        make.top.equalTo(self.mas_top);
        
        make.bottom.equalTo(self.mas_bottom);
        
        make.width.equalTo(self.zButton.mas_width);
        
    }];
    
    [self.zButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.rightView.mas_right);
        
        make.top.equalTo(self.mas_top);
        
        make.bottom.equalTo(self.mas_bottom);
        
        make.right.equalTo(self.mas_right);
        
    }];
    
    [self.leftView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.mas_top);
        
        make.bottom.equalTo(self.mas_bottom);
        
        make.left.equalTo(self.zfButton.mas_right);
        
        make.width.equalTo(@1);
        
    }];
    
    [self.rightView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.mas_top);
        
        make.bottom.equalTo(self.mas_bottom);
        
        make.left.equalTo(self.plButton.mas_right);
        
        make.width.equalTo(@1);
        
    }];
}
-(UIButton *)zfButton{

    if (_zfButton == nil) {
        _zfButton = [[UIButton alloc]init];
        
        [_zfButton setImage:[UIImage imageNamed:@"timeline_icon_retweet"] forState:UIControlStateNormal];
        
        [_zfButton setTitle:@"转发" forState:UIControlStateNormal];
        
        [_zfButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        
        _zfButton.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _zfButton;


}
-(UIButton *)plButton{

    if (_plButton == nil) {
        _plButton =[[UIButton alloc]init];
        
        [_plButton setImage:[UIImage imageNamed:@"timeline_icon_comment"] forState:UIControlStateNormal];
        
        [_plButton setTitle:@"评论" forState:UIControlStateNormal];
        
        [_plButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        
        _plButton.titleLabel.font = [UIFont systemFontOfSize:12];
    }

    return _plButton;

}
-(UIButton *)zButton{

    if (_zButton == nil) {
        _zButton = [[UIButton alloc]init];
        
        [_zButton setImage:[UIImage imageNamed:@"timeline_icon_unlike"] forState:UIControlStateNormal];
        
        [_zButton setTitle:@"赞" forState:UIControlStateNormal];
        
        [_zButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        
        _zButton.titleLabel.font = [UIFont systemFontOfSize:12];
    }

    return _zButton;
}
-(UIView *)leftView{

    if (_leftView == nil) {
    
        _leftView = [[UIView alloc]init];
        
        _leftView.backgroundColor = [UIColor lightGrayColor];
        
    }
    return _leftView;

}
-(UIView *)rightView{

    if (_rightView == nil) {
        
        _rightView = [[UIView alloc]init];
        
        _rightView.backgroundColor = [UIColor lightGrayColor];
    }
    return _rightView;

}
-(void)setHomeCellModel:(ZRHomeCellModel *)homeCellModel{

    _homeCellModel = homeCellModel;
    
    if (homeCellModel.reposts_count > 0) {
        
        [self.zfButton setTitle:[NSString stringWithFormat:@"%d",homeCellModel.reposts_count] forState:UIControlStateNormal];
    }else{
    
        [self.zfButton setTitle:@"转发" forState:UIControlStateNormal];
    }
    
    if (homeCellModel.comments_count > 0) {
        
        [self.plButton setTitle:[NSString stringWithFormat:@"%d",homeCellModel.comments_count] forState:UIControlStateNormal];
    }else{
        
        [self.plButton setTitle:@"评论" forState:UIControlStateNormal];
    }
    
    if (homeCellModel.attitudes_count > 0) {
        
        [self.zButton setTitle:[NSString stringWithFormat:@"%d",homeCellModel.attitudes_count] forState:UIControlStateNormal];
        
    }else{
        
        [self.zButton setTitle:@"赞" forState:UIControlStateNormal];
    }


}

@end
